package com.iring.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.iring.interceptor.AuthTokenInterceptor;
import com.iring.interceptor.UserInterceptor;


/**
 * webmvc配置
 *
 * @author wanggan
 */
@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

    @Autowired
    UserInterceptor userInterceptor;

    @Autowired
    AuthTokenInterceptor authTokenInterceptor;

    /**
     * {@inheritDoc}<br>
     * 设置拦截器,并排除一些访问路径
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(authTokenInterceptor).addPathPatterns("/admin/**");
         InterceptorRegistration login = registry.addInterceptor(userInterceptor);
         login.addPathPatterns("/admin/**");
    }
}
